define(
		[ 'jquery', 'bootstrap', 'select2', 'validate', 'validate.en',
				'koala-search', 'shiftformloadtime', 'modalSearch' ],
		function($, validate) {
			return {

				init : function() {
					this.initPage();
					this.beforeSubmit();
				},

				initPage : function() {

					$(document).find('form').bt_validate();

				},

				beforeSubmit : function() {

					$("#validate-form")
							.shiftform(
									{
										beforeSubmit : function(el) {

											// validate radio
											var shipmentNumber = null;
											var isChooseOne = false;
											var radio = $('input[name = shipmentNumber]');
											for (var i = 0; i < radio.length; i++) {
												if (radio[i].checked) {
													isChooseOne = true;
													shipmentNumber = radio[i].value;
													break;
												}

											}
											if (!isChooseOne) {
												var html = '<p  class="hint-message radio-check-message" style="margin: 20px 0 20px 0; color:#ce082b" >'
														+ '<i class="glyphicon glyphicon-remove"></i>&nbsp;请选择至少一个调度指令'
														+ '</p>';
												$(".radio-check").append(html);
												return false;
											}

											// set action and data-redirect
											$("#validate-form").attr(
													"action",
													"shipment-lines/"
															+ shipmentNumber
															+ "/validate");

											$("#validate-form").trigger(
													"validate.ajax.submit");
											return $.bt_validate.result[$.bt_validate.form_id];
										}
									})

				},

			}
		})
